<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/4
 * Time: 11:09
 */
//针对于用户的数据的封装，继承，多态
//面向对线的编程方法
class rootDB
{

    //管理员的添加信息
    public function add_admin($user, $password,$code,$addtime)
    {
        $sql = "insert into weixin(name,pass,code,addtime) values('$user','$password','$code','$addtime')";
        $dbConn = new DbCon();
        return $dbConn->add($sql);

    }
 public function AdminLogin($user,$password,$code)
  {
          $sql = "select * from weixin where name='$user' and pass='$password'and code='$code'";
          $dbConn = new DbCon();
          return $dbConn->query($sql);

  }
  public  function AdminLoginU($user,$password)
    {
        $sql = "select * from weixin where name='$user' and pass='$password'";
        $dbConn = new DbCon();
        return $dbConn->query($sql);

    }
    //管理员的添加信息
    public function add_user($user, $pass,$addtime)
    {
        $sql = "insert into weixin(name,pass,addtime) values('$user','$pass','$addtime')";
        $dbConn = new DbCon();
        return $dbConn->add($sql);

    }
    //所有成员 的查询
    public function selecAlltUser()
    {
        $sql = "select * from weixin";
        $dbConn = new DbCon();
        return $dbConn->query($sql);

    }
    function selecAllProp(){
        $sql = "select * from proposal";
        $dbConn = new DbCon();
        return $dbConn->query($sql);
    }
    function selecPageProp($start,$pagesize){

        $sql = "select * from proposal limit $start,$pagesize";
        $dbConn = new DbCon();
        return $dbConn->query($sql);

    }
    function selecOneProp($id){

        $sql = "select * from proposal where id='$id'";
        $dbConn = new DbCon();
        return $dbConn->query($sql);

    }
    function add_prop($name,$img,$content,$tel,$addtime){
        $sql = "insert into proposal(name,img,content,tel,addtime) values('$name','$img','$content','$tel','$addtime')";
        $dbConn = new DbCon();
        return $dbConn->add($sql);

    }
    function add_examine($id,$code){
        $sql="update proposal set examine='$code' where id='$id'";
        $dbConn = new DbCon();
        return $dbConn->modify($sql);
    }

    function update_student($id,$code){
        $sql="update student set examine='$code' where id='$id'";
        $dbConn = new DbCon();
        return $dbConn->modify($sql);

    }
    //查询模块
    function select_propALL($name){

        $sql = "select * from proposal where name='$name'";
        $dbConn = new DbCon();
        return $dbConn->query($sql);

    }
    function selecAllPropCode($code){
        $sql = "select * from proposal where examine='$code' order by id desc ";
        $dbConn = new DbCon();
        return $dbConn->query($sql);

    }
   public function query_admin_all(){
        $sql = "select * from weixin ";
        $dbConn = new DbCon();
        return $dbConn->query($sql);
    }
 public function query_admin_page($start,$pagesize){
        $sql = "select * from weixin limit $start,$pagesize";
        $dbConn = new DbCon();
        return $dbConn->query($sql);
    }
    public  function query_member_all(){
        $sql = "select * from admin ";
        $dbConn = new DbCon();
        return $dbConn->query($sql);
    }
    public   function query_member_page($start,$pagesize){
        $sql = "select * from admin limit $start,$pagesize";
        $dbConn = new DbCon();
        return $dbConn->query($sql);
    }
    //查询意见
    public  function query_idea_all(){
        $sql = "select * from proposal ";
        $dbConn = new DbCon();
        return $dbConn->query($sql);
    }
    public   function query_idea_page($start,$pagesize){
        $sql = "select * from proposal limit $start,$pagesize";
        $dbConn = new DbCon();
        return $dbConn->query($sql);
    }
    //查询意见

    //删除模块
    public   function dell_admin($id){
        $sql="delete from admin where id='$id'";
        $dbCoun=new DbCon();
        return $dbCoun->query($sql);

    }
    public function dell_proposal($id){
        $sql="delete from proposal where id='$id'";
        $dbCoun=new DbCon();
        return $dbCoun->query($sql);
    }
    public function dell_user($id){
        $sql="delete from user where id='$id'";
        $dbCoun=new DbCon();
        return $dbCoun->query($sql);

    }
    public function query_user_all(){
        $sql = "select * from user ";
        $dbConn = new DbCon();
        return $dbConn->query($sql);
    }

    public function query_idear_examine(){
        $sql = "select * from proposal where examine=0 ";
        $dbConn = new DbCon();
        return $dbConn->query($sql);
    }
public function query_user_page($start,$pagesize){
        $sql = "select * from user limit $start,$pagesize";
        $dbConn = new DbCon();
        return $dbConn->query($sql);
    }
    //show
    public function query_idea_self($id){
        $sql="select * from proposal where id='$id'";
        $dbCoun=new DbCon();
        return $dbCoun->query($sql);

}
//
public function query_admin($admin){
    $sql="select * from weixin where name='$admin'";
    $dbCoun=new DbCon();
    return $dbCoun->query($sql);
}
//报名列表

    public function query_sign_all(){
        $sql = "select * from student ";
        $dbConn = new DbCon();
        return $dbConn->query($sql);
    }
    public function query_sign_page($start,$pagesize){
        $sql = "select * from student limit $start,$pagesize";
        $dbConn = new DbCon();
        return $dbConn->query($sql);
    }
    public function query_student_self($id){
        $sql="select * from student where id='$id'";
        $dbCoun=new DbCon();
        return $dbCoun->query($sql);

    }
    public function dell_student($id){
        $sql="delete from student where id='$id'";
        $dbCoun=new DbCon();
        return $dbCoun->delete($sql);
    }
}